package com.example.androidunlockviewdemo;

import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.androidunlockviewdemo.view.LockView;

/**
 * @author: smile
 * @date: 2025/9/13 3:06
 * @desc: 描述
 */
public class TestActivity extends AppCompatActivity {
    private LockView lockView; // 自定义九宫格手势解锁控件
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    protected void onResume() {
        super.onResume();
        lockView = (LockView) findViewById(R.id.lockview_main_lv_lockview);
        // 初始化事件
        initEvents();
    }

    private void initEvents() {
        lockView.setOnUnlockListener(new LockView.OnUnlockListener() {
            // 设置在什么情况下视为解锁成功
            @Override
            public boolean isUnlockSuccess(String result) {
                return "369258".equals(result);
            }

            // 当解锁成功时回调的方法
            @Override
            public void onSuccess() {
                Toast.makeText(TestActivity.this, "Unlock Success!", Toast.LENGTH_SHORT).show();
            }

            // 当解锁失败时回调的方法
            @Override
            public void onFailure() {
                Toast.makeText(TestActivity.this, "Unlock Failed!", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
